package com.goods.controller.business;

import com.goods.business.service.HealthService;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.HealthVO;
import com.goods.common.vo.system.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @Description: 健康打卡
 * @Author: Mr.Cao
 * @DateTime: 2021/11/10 23:29
 * BMW F750GS
 **/
@RestController
@RequestMapping("business/health")
public class HealthController {

    @Autowired
    private HealthService healthService;
    /**
     * 检查今日是否打卡
     * */
    //http://www.localhost:8989/business/health/isReport
    @GetMapping("isReport")
    public ResponseBean isReport(HttpServletRequest request){
        HealthVO healthVO =  healthService.isReport(request);
        return ResponseBean.success(healthVO);
    }

    /**
     * 用户打卡
     * */
    //http://www.localhost:8989/business/health/report
    @PostMapping("report")
    public ResponseBean report(@RequestBody HealthVO healthVO, HttpServletRequest request){
        healthService.report(healthVO,request);
        return ResponseBean.success();
    }
    /**
     * 分页查询签到记录
     * */
    //http://www.localhost:8989/business/health/history?pageSize=4&pageNum=1
    @GetMapping("history")
    public ResponseBean history(@RequestParam Map queryMap, HttpServletRequest request){
       PageVO pageVO =  healthService.history(queryMap,request);
        return ResponseBean.success(pageVO);
    }
}
